#ifndef SETTINGS_H
#define SETTINGS_H

#include <QSettings>

//! Settings manager.
class AllSettings : public QSettings
{
public:
	AllSettings(void);
	~AllSettings(void);
	
// Add setter and getter for a setting.
// SETTING:		name of the setting.
// KEY:			key which used to store setting.
// TYPE:		value type.
// GETMETHOD:	name of QVariant's method that 
//				perform conversion to needed type.
#define ADDPROP(SETTING, KEY, DEFAULT, TYPE, GETMETHOD) \
	TYPE get ## SETTING() \
		{ return value(KEY, DEFAULT).GETMETHOD(); } \
	void set ## SETTING(const TYPE& value) { setValue(KEY, value); }
	
// Add setter and getter for a setting with string value.
// SETTING:		name of the setting.
// KEY:			key which used to store setting.
#define ADDSTRINGPROP(SETTING, KEY, DEFAULT) \
	ADDPROP(SETTING, KEY, DEFAULT, QString, toString)
	
// Add setter and getter for a setting with integer value.
// SETTING:		name of the setting.
// KEY:			key which used to store setting.
#define ADDINTPROP(SETTING, KEY, DEFAULT) \
	ADDPROP(SETTING, KEY, DEFAULT, int, toInt)
	
	// Author name.
	ADDSTRINGPROP(AuthorName, "Common/AuthorName", "Vadym Hulakov")
	// License description.
	ADDSTRINGPROP(License, "Common/License", "GPL 2")
	// Copyright description.
	ADDSTRINGPROP(Copyright, "Common/Copyright", 
		"Copyright (C) 2010. All rights reserved.")

	// Tabs width.
	ADDINTPROP(TabsWidth, "CodeGen/TabWidth", 4)
};

//! Application settings.
extern AllSettings Settings;

#endif